<?php
/**
 *  View Interface
 *
 */
namespace Yz\modules\Error;
use \Yz_HTTP_Response_Interface as Response;
class View_Error
    extends \Yz_View_Template
    implements \Yz_View_Interface
{

    protected $errorCode = Response::STATUS_OK;

    /**  declare the NOT_FOUND error
     *
     */
    public function declareNotFound()
    {
        $this->errorCode = Response::STATUS_NOT_FOUND;
        return $this;
    }

    /**  declare the INTERNAL_SERVER_ERROR error
     *
     */
    public function declareServerError()
    {
        $this->errorCode = Response::STATUS_INTERNAL_SERVER_ERROR;
        return $this;
    }

    /**  declare the FORBIDDEN error
     *
     */
    public function declareForbidden()
    {
        $this->errorCode = Response::STATUS_FORBIDDEN;
        return $this;
    }

    /**
     *  usually called by the response object which is supplied as argument
     *      in order to be notified by the view (set headers, status etc)
     *  @param Yz_HTTP_Response_Interface $rs
     *  @return string
     */
    public function render(Response $rs)
    {
        $rs->setStatus($this->errorCode);
        return parent::render($rs);
    }

} // class

